package com.aaa.service.systemmanage.impl;

import com.aaa.aspect.InsertAnn;
import com.aaa.aspect.UpdateAnn;
import com.aaa.dao.systemmanage.RoleMenuDao;
import com.aaa.service.systemmanage.RoleMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 角色和菜单关联表(RoleMenu)表服务实现类
 *
 * @author makejava
 * @since 2022-09-03 18:44:25
 */
@Service("roleMenuService")
public class RoleMenuServiceImpl implements RoleMenuService {
    @Resource
    private RoleMenuDao roleMenuDao;

    @InsertAnn
    @Override
    public void insert(int roleId, String[] menusId) {
        for (int i = 0; i < menusId.length; i++) {
            roleMenuDao.insert(roleId, menusId[i]);
        }
    }

    @UpdateAnn
    @Override
    public void update(Integer roleId, String[] menusId) {
        roleMenuDao.delete(roleId);
        for (int i = 0; i < menusId.length; i++) {
            roleMenuDao.insert(roleId, menusId[i]);
        }
    }


}
